<?php

namespace App\Http\Requests\Backend\Message;

use Illuminate\Foundation\Http\FormRequest;

class NewsMessageRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $method = $this->method();
        switch ($method){
            case 'POST':
                return [
                    'content' => 'required|string',
                ];
                break;
            case 'PUT':
                return [
                    'is_show' => 'sometimes|required|in:1,2',
                    'content'=> 'sometimes|required|string'
                ];
                break;
        }
    }



    public function messages()
    {
        return [
            'content.string' => '快讯内容必须为字符串',
            'content.required' => '快讯内容不能为空',
            'is_show.in' => '显示类型传递错误',
        ];
    }
}
